<template>
  <div class="tab-control">
    <div class="tab-control-item"
         v-for="(item, index) in tabControlList"
         :key="index"
         :class="{active: index === currentIndex}"
         @click="tabControlClick(index)">
      <span>{{ item }}</span>
    </div>
  </div>
</template>

<script>
  export default {
    name: "TabControl",
    props: {
      tabControlList: {
        type: Array,
        default() {
          return [];
        }
      }
    },
    data() {
      return {
        currentIndex: 0,
      }
    },
    methods: {
      tabControlClick(index) {
        if (this.currentIndex === index) return;
        this.currentIndex = index;
        this.$emit("tabControlClick", index)
      }
    }
  }
</script>

<style scoped>
  .tab-control {
    width: 100%;
    height: 40px;
    display: flex;
    /*background-color: skyblue;*/
    /*margin-top: 5px;*/
  }
  .tab-control-item {
    flex: 1;
    text-align: center;
    line-height: 40px;
  }
  .tab-control-item span {
    padding: 5px;
    font-size: 15px;
  }
  .active {
    color: #ff5777;
  }
  .active span {
    border-bottom: 2px solid #ff5777;
  }
</style>
